#ifndef __VV_CONFIG_H
#define __VV_CONFIG_H
	#include "includes.h"

	#define DATA_EEPROM_ADDRESS 0x8080000

	#define FREQ_RANGE_0 1000

	#define FREQ_RANGE_1 35000000
	#define FREQ_RANGE_2 75000000
	#define FREQ_RANGE_3 175000000
	#define FREQ_RANGE_4 425000000
	#define FREQ_RANGE_5 995000000
	#define FREQ_RANGE_6 2215000000
	#define FREQ_RANGE_7 4000000000

	//the end 1k bytes used to store calibrationg table.
	#define DATA_EEPROM_CALIB_ADDRESS (0x8080000 + 1024)

	extern uint32_t freq_range[];
	uint16_t vv_get_calib_point_index (uint32_t freq);

	//range 0 - (range1-1) generated by dds, range 0
	//range N -  range(N+1) - 1 channelN
	//...


	//clabiration table
	#define CALIB_COUNT_PER_RANGE	(uint32_t)5

	#define CALIB_POINT_COUNT (7*CALIB_COUNT_PER_RANGE)


	typedef struct {
		uint32_t freq;
		uint8_t gain;
	} calib_point_t;


	extern TIM_HandleTypeDef htim6;

	void vv_write_config_byte (uint8_t index, uint8_t value);
	uint8_t vv_read_config_byte (uint8_t index);

	uint8_t vv_get_calib_value_by_freq (uint32_t freq);
	void vv_load_calib_table (void);

	void vv_calib_demo (void);

	void vv_set_calib_point (uint16_t index, uint8_t gain);
	uint8_t vv_get_calib_point (uint16_t index);
	//void vv_random (void);

	uint32_t vv_random_freq (void);
	uint32_t vv_random_freq_10hz (void);
	void vv_config_tim6 (uint16_t period);
	void vv_beep(uint8_t value);
	
#endif